﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MetaCollection.ContentService.Template
{
	/// <summary>
	///     Checks if a string contains a given string
	///     
	///     For example:
	///     {{ value|contains:"news" }}
	///     If value is http://mine.mt.gov/news/default.aspx the output would be true
	///     Note that the following {{ value|contains:"News" }} would return false.
	///     At this time this is not case insensitive.
	/// </summary>
	public class ContainsFilter : NDjango.Interfaces.IFilter
	{

		#region IFilter Members

		public object DefaultValue
		{
			get { return string.Empty; }
		}

		public object PerformWithParam(object @value, object @parameter)
		{
			if (@value == null || @parameter == null)
				throw new ArgumentNullException();
			return @value.ToString().Contains(@parameter.ToString());
		}

		#endregion

		#region ISimpleFilter Members

		public object Perform(object @value)
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}
